package com.gitee.wsl.compose.state.ext

import androidx.compose.runtime.Composable
import androidx.compose.runtime.ProduceStateScope
import com.gitee.wsl.compose.state.S


/**
 * 生成多值 时 使用
 * produceState<OpResult<ImageBitmap>>(initialValue = OpResult.Loading){
 *                             for(i in 0 until imageRepository.imageLst.size) {
 *                                 var image = imageRepository.loadImageByUrl(imageRepository.imageLst[i])
 *                                 value = if (image == null) {
 *                                     OpResult.Error
 *                                 } else {
 *                                     OpResult.Success(image)
 *                                 }
 *                             }
 */
@Suppress("ProduceStateDoesNotAssignValue")
@Composable
fun <T> S.produceState(
    initialValue: T,
    producer: suspend ProduceStateScope<T>.() -> Unit
) =  androidx.compose.runtime.produceState(initialValue,producer)

@Suppress("ProduceStateDoesNotAssignValue")
@Composable
fun <T> S.produceState(
    initialValue: T,
    key1: Any?,
    producer: suspend ProduceStateScope<T>.() -> Unit
) = androidx.compose.runtime.produceState(initialValue,key1,producer)

@Suppress("ProduceStateDoesNotAssignValue")
@Composable
fun <T> S.produceState(
    initialValue: T,
    key1: Any?,
    key2: Any?,
    producer: suspend ProduceStateScope<T>.() -> Unit
) = androidx.compose.runtime.produceState(initialValue,key1,key2,producer)

@Suppress("ProduceStateDoesNotAssignValue")
@Composable
fun <T> S.produceState(
    initialValue: T,
    key1: Any?,
    key2: Any?,
    key3: Any?,
    producer: suspend ProduceStateScope<T>.() -> Unit
) = androidx.compose.runtime.produceState(initialValue,key1,key2,key3,producer)
